package io.vertx.starter;

import io.vertx.core.AbstractVerticle;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.asyncsql.AsyncSQLClient;
import io.vertx.ext.asyncsql.PostgreSQLClient;
import io.vertx.ext.sql.SQLClient;

/**
 * @author zhangls
 */
public class MainVerticle extends AbstractVerticle {

  AsyncSQLClient postgreSQLClient;

  @Override
  public void start() {
//    vertx.createHttpServer()
//      .requestHandler(req -> req.response().end("Hello Vert.x!"))
//      .listen(8080);

    JDBCClient client = JDBCClient.createShared(vertx, new JsonObject().clear()
      .put("provider_class", "io.vertx.ext.jdbc.spi.impl.HikariCPDataSourceProvider")
      .put("jdbcUrl", "jdbc:postgresql://127.0.0.1:5432/mydb")
      .put("username", "postgres")
      .put("password","password")
      .put("driverClassName", "org.postgresql.Driver")
      .put("maximumPoolSize", 30),"mypool");

    JsonObject postgreSQLClientConfig = new JsonObject().put("127.0.0.1", "pgdb.asiainfo");
    SQLClient postgreSQLClient = PostgreSQLClient.createShared(vertx, postgreSQLClientConfig);
  }

}
